package com.bw.zg3.notice

import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.bw.base.entity.GGEntityResultItem
import com.bw.base.mvvm.BaseViewModel
import com.bw.base.net.ApiServer
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
@HiltViewModel
class NoticeViewModel @Inject constructor(val apiServer: ApiServer):BaseViewModel() {
    fun getNotices():Flow<PagingData<GGEntityResultItem>>{
        return Pager(config= PagingConfig(pageSize = 10), pagingSourceFactory = {
            NoticeDataSource(apiServer)
        }).flow.cachedIn(viewModelScope)
    }
}